﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.DAL.DocumentCenter;
using MS.InformationManagement.Support;
using Microsoft.SharePoint;
using MS.InformationManagement.Support.Constants;
using MS.InformationManagement.DAL.DTOs;

namespace MS.InformationManagement.BLL.SearchSender
{
    public class PersonSearchSender : BaseSearchSender<Personas>
    {

        public override IEnumerable<Personas> GetSenders(string camlQuery)
        {
            SPQuery query = new SPQuery();
            query.Query = camlQuery;
            SPListItemCollection listItems = SPContext.Current.Web.Lists[GlobalConstants.LIST_SENDERS].GetItems(query);
            PersonContactDTO personDTO = new PersonContactDTO(listItems);
            return personDTO.GetEntities();
        }

        public IEnumerable<Personas> GetPerson(string camlQuery, int pageIndex, int pageSize, out int totalRecords)
        {
            int startingPosition = pageIndex * pageSize;
            var result = GetSenders(camlQuery);
            totalRecords = result.Count();
            return result.Skip(startingPosition).Take(pageSize);
        }
    }
}
